Security News
NIST Misses 2024 Deadline to Clear NVD Backlog
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
strip-indent
Advanced tools
The strip-indent npm package is used to remove the leading whitespace from every line in a given text block. This is particularly useful when working with multi-line strings that need to be displayed without indentation or when processing template literals in JavaScript that should not retain the formatting of the source code.
Strip indentation from a multi-line string
This feature allows you to remove the common leading whitespace from all lines in a text block, making it easier to handle formatted multi-line strings without unwanted indentation.
const stripIndent = require('strip-indent');
const text = ` line one
line two
line three`;
console.log(stripIndent(text));
Dedent is similar to strip-indent but also trims the trailing newline. It is often used in template literals to avoid first-line indentation and to ensure that the output does not end with a newline, making it slightly different in its approach compared to strip-indent.
While strip-indent removes indentation, indent-string adds indentation to each line in a string. This package can be considered the opposite of strip-indent. It allows specifying the number of spaces or the type of indentation (spaces or tabs), offering more flexibility depending on the user's needs.
Strip leading whitespace from each line in a string
The line with the least number of leading whitespace, ignoring empty lines, determines the number to remove.
Useful for removing redundant indentation.
$ npm install --save strip-indent
const stripIndent = require('strip-indent');
const str = '\tunicorn\n\t\tcake';
/*
unicorn
cake
*/
stripIndent('\tunicorn\n\t\tcake');
/*
unicorn
cake
*/
MIT © Sindre Sorhus
FAQs
Strip leading whitespace from each line in a string
The npm package strip-indent receives a total of 16,055,273 weekly downloads. As such, strip-indent popularity was classified as popular.
We found that strip-indent demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.